using System;
using System.Drawing;
using System.Windows.Forms;

class MyForm:Form
{
	private System.Windows.Forms.Button OK;
	private System.Windows.Forms.CheckBox checkBox1;
	private System.Windows.Forms.Label zhubicen;
	MyCheckBox[] achkbox;
	public MyForm()
	{
		achkbox = new MyCheckBox[4];
		int cyText = Font.Height;
		int cxText =cyText/2;
		string[] astrText={"Bold","Italic","UnderLine","StrikeOut"};
		for(int i=0;i<4;i++)
		{
			achkbox[i] = new MyCheckBox();
			achkbox[i].Parent = this;
			achkbox[i].Text = astrText[i];
			achkbox[i].Location = new Point(0,cyText*(3*i+4));
			achkbox[i].CheckedChanged +=new EventHandler(CheckedChanged);
		}
		Controls.AddRange(achkbox);
		InitializeComponent();
	}

	
	private void CheckedChanged(object sender, EventArgs e)
	{
		if(((Control)sender).GetType()==typeof(MyCheckBox))
		{
			MessageBox.Show("MyCheckBox!");
			MyCheckBox m=(MyCheckBox)sender;
			m.fs=FontStyle.Bold;
		}
		if(((Control)sender).GetType()==typeof(CheckBox))
			MessageBox.Show("CheckBox");
//		for(int i=0;i<4;i++)
//		{
//			if(achkbox[i].Checked)
//			{
//				string str=string.Format("You clicked the {0}",i);
//				MessageBox.Show(str);
//			}
//		}
	}

	private void InitializeComponent()
	{
		this.OK = new System.Windows.Forms.Button();
		this.checkBox1 = new System.Windows.Forms.CheckBox();
		this.zhubicen = new System.Windows.Forms.Label();
		this.SuspendLayout();
		// 
		// OK
		// 
		this.OK.Location = new System.Drawing.Point(152, 104);
		this.OK.Name = "OK";
		this.OK.Size = new System.Drawing.Size(120, 40);
		this.OK.TabIndex = 0;
		this.OK.Text = "button1";
		this.OK.Click += new System.EventHandler(this.OK_Click);
		// 
		// checkBox1
		// 
		this.checkBox1.Location = new System.Drawing.Point(160, 64);
		this.checkBox1.Name = "checkBox1";
		this.checkBox1.Size = new System.Drawing.Size(96, 24);
		this.checkBox1.TabIndex = 1;
		this.checkBox1.Text = "checkBox1";
		this.checkBox1.ThreeState = true;
		this.checkBox1.CheckedChanged += new System.EventHandler(this.CheckedChanged);
		// 
		// zhubicen
		// 
		this.zhubicen.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
		this.zhubicen.FlatStyle = System.Windows.Forms.FlatStyle.Popup;
		this.zhubicen.Location = new System.Drawing.Point(168, 216);
		this.zhubicen.Name = "zhubicen";
		this.zhubicen.TabIndex = 2;
		this.zhubicen.Text = "label1";
		this.zhubicen.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
		this.zhubicen.Click += new System.EventHandler(this.zhubicen_Click);
		// 
		// MyForm
		// 
		this.AutoScaleBaseSize = new System.Drawing.Size(6, 14);
		this.ClientSize = new System.Drawing.Size(292, 266);
		this.Controls.Add(this.zhubicen);
		this.Controls.Add(this.checkBox1);
		this.Controls.Add(this.OK);
		this.Name = "MyForm";
		this.ResumeLayout(false);

	}
	private void OK_Click(object sender, System.EventArgs e)
	{
		MessageBox.Show("You click the buttion!");
	
	}

	private void zhubicen_Click(object sender, System.EventArgs e)
	{
		MessageBox.Show("You click the lable");
		((Label)sender).Text="ZHUBICEN";
	
	}

	
}
class MyCheckBox:CheckBox
{
	public FontStyle fs;
}
class MyAPP
{
	static void Main()
	{
		Application.Run(new MyForm());
	}
}


